{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e746ddb9",
   "metadata": {},
   "source": [
    "## 元组(tuple)\n",
    "\n",
    "1. 它是和list几乎完全一样的序列数据\n",
    "2. 它与list不同的地方是，不可变（因为不可变，所以几乎没有方法）\n",
    "3. 元组的形式： (1,2,34,5) 对比 元组()  列表[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f0479406",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"ccc\",\"vvv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "51ff4171",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('ccc', 'vvv')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c2a3d792",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "54601109",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"ccc\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "bdd99c46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'cc', 'age': 20}\n"
     ]
    }
   ],
   "source": [
    "## 字典\n",
    "cc = {\"name\":\"cc\",\n",
    "        \"age\": 20,\n",
    "     }\n",
    "print(cc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "4c4e8e4c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cc\n",
      "20\n"
     ]
    }
   ],
   "source": [
    "print(cc[\"name\"])\n",
    "print(cc[\"age\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "8fbfb5a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15\n"
     ]
    }
   ],
   "source": [
    "cc[\"age\"]=15\n",
    "print(cc[\"age\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "954e576b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'age': 15}\n"
     ]
    }
   ],
   "source": [
    "cc.pop(\"name\")\n",
    "print(cc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bc1c7d51",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n"
     ]
    }
   ],
   "source": [
    "cc.clear()\n",
    "print(cc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4cd4fcca",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
